import {button, center, formInput, grid, header, right, rightContent, search} from "@/css/VueCss.module.scss";

export default {
    title: '基本配置',
    order: 1,
    items: [{
        region: 'center',
        class: center,
        layout: 'vertical',
        items: [{
            items: [{
                id: 'search',
                class: search,
                widget: 'search',
                text: {
                    field: 'keywords',
                    placeholder: '请输入名称'
                },
                onSearch: [{
                    action: 'grid-load',
                    target: '$widgets.grid',
                    params: {
                        name: '"organization_position"',
                        keywords: '$params.keywords',
                    }
                }]
            }, {
                class: header,
                layout: 'horizontal',
                items: [{
                    class: button,
                    widget: 'button',
                    value: '新增',
                    onClick: [{
                        action: 'call',
                        target: '$widgets.form',
                        method: 'reset'
                    }, {
                        action: 'call',
                        target: '$widgets.grid',
                        method: 'clearSelection'
                    }]
                }, {
                    class: button,
                    widget: 'button',
                    value: '删除',
                    onClick: [{
                        action: 'confirm',
                        title: '删除数据',
                        message: '是否删除勾选数据?',
                        confirm: [{
                            var: 'checkedItemIds',
                            action: 'array-value',
                            target: '$widgets.grid.checkedItems',
                            key: 'id'
                        }, {
                            action: 'print',
                            description: '列表勾选项',
                            value: '$vars.checkedItemIds'
                        }, {
                            action: 'service',
                            // path: 'system/dictionary/config/allremove',
                            params: {
                                name: '"organization_position"',
                                id: '$vars.checkedItemIds'
                            }
                        }, {
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }]
                    }]
                }]
            }]
        }, {
            id: 'grid',
            class: grid,
            widget: 'grid',
            service: {
                path: 'system/storage/basic/list',
            },
            pageSize: 20,
            columns: [{
                prop: 'type_name',
                label: '类型名称',
                width: 220
            }, {
                prop: 'state_value',
                label: '状态',
                dictionary: 'common/static/state',
            }, {
                prop: 'remarks',
                label: '备注'
            }],
            buttons: [{
                value: '删除',
                type: 'danger',
                onClick: [{
                    action: 'confirm',
                    title: '删除数据',
                    message: '是否删除该条数据?',
                    confirm: [{
                        action: 'service',
                        path: 'system/storage/basic/list',
                        params: {
                            id: '$params.id'
                        }
                    }, {
                        action: 'call',
                        target: '$widget',
                        method: 'reload'
                    }]
                }]
            }],
            flex: true,
            enableCheckboxColumn: true,
            onRowselect: [{
                action: 'call',
                target: '$widgets.form',
                method: 'setValue',
                params: '$params'
            }],
        }]
    }, {
        region: 'right',
        class: right,
        items: [{
            id: 'title',
            widget: 'public-titleright',
            title: '编辑修改',
        }, {
            class: rightContent,
            items: [{
                id: 'form',
                widget: 'form',
                fields: [{
                    class: formInput,
                    itemId: 'type_name',
                    placeholder: '请输入名称',
                    widget: 'text',
                    label: '名称',
                }, {
                    class: formInput,
                    itemId: 'remarks',
                    placeholder: '请输入备注',
                    widget: 'text',
                    label: '备注',
                }, {
                    itemId: 'state_value',
                    widget: 'form-radio',
                    label: '状态',
                    value: 1,
                    options: [{
                        value: 1,
                        text: '启用'
                    }, {
                        value: 0,
                        text: '禁用'
                    }],
                }],
                buttons: [{
                    value: '保存',
                    type: 'primary',
                    onClick: [{
                        action: 'confirm',
                        title: '表单保存',
                        message: '是否保存表单?',
                        confirm: [{
                            action: 'service',
                            path: 'system/storage/basic/save',
                            params: {
                                id: '$widget.value.id',
                                uuid: '$widget.value.uuid',
                                type: '$widget.value.type_name',
                                state: '$widget.value.state_value',
                                remarks: '$widget.value.remarks',
                            },
                        }, {
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }]
                    }]
                }],
                flex: true
            }]
        }]
    }]
};
